package com.hyj.app.demo;

import android.os.Parcel;
import android.os.Parcelable;

public class AppInfo implements Parcelable {
    private String appName;
    private String text;

    public AppInfo(String appName, String text) {
        this.appName = appName;
        this.text = text;
    }

    // Parcelable实现
    protected AppInfo(Parcel in) {
        appName = in.readString();
        text = in.readString();
    }

    public static final Creator<AppInfo> CREATOR = new Creator<AppInfo>() {
        @Override
        public AppInfo createFromParcel(Parcel in) {
            return new AppInfo(in);
        }

        @Override
        public AppInfo[] newArray(int size) {
            return new AppInfo[size];
        }
    };

    // Getter方法
    public String getAppName() { return appName; }
    public String getText() { return text; }

    @Override
    public int describeContents() { return 0; }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(appName);
        dest.writeString(text);
    }
}